package com.skycong.hello77.activity.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.Window;
import android.widget.RadioButton;
import com.skycong.hello77.R;
import com.skycong.hello77.activity.mydialogcar.MyProgressDialog_car;
import com.skycong.hello77.fragment.AFagment;
import com.skycong.hello77.fragment.BFragment;
import com.skycong.hello77.fragment.CFragment;
import com.skycong.hello77.fragment.DFragment;

/**
 * @author ruanmingcong
 * @date 2018/1/15 21:52
 */
public class TabFragmentActivity  extends FragmentActivity implements View.OnClickListener{
    private FragmentManager manager=getSupportFragmentManager();
    private FragmentTransaction transaction;
    private RadioButton a,b,c,d;
    private MyProgressDialog_car myProgressDialog_car;//加载中的弹框
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_fra);

        myProgressDialog_car = new MyProgressDialog_car(this);

        a = (RadioButton) findViewById(R.id.a);
        b = (RadioButton) findViewById(R.id.b);
        c= (RadioButton) findViewById(R.id.c);
        d = (RadioButton) findViewById(R.id.d);

        transaction= manager.beginTransaction();
        transaction.add(R.id.layout,new AFagment());
        transaction.commit();
        a.setOnClickListener(this);
        b.setOnClickListener(this);
        c.setOnClickListener(this);
        d.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        transaction = manager.beginTransaction();
        switch (v.getId()){
            case R.id.a:{
                myProgressDialog_car.show();
                myProgressDialog_car.displayTipTextshowWithOut();
                myProgressDialog_car.setMsg("正在加载，请稍后");
                transaction.replace(R.id.layout,new AFagment());
                break;
            }
            case R.id.b:{
                transaction.replace(R.id.layout,new BFragment());
                break;
            }
            case R.id.c:{
                transaction.replace(R.id.layout,new CFragment());
                break;
            }
            case R.id.d:{
                transaction.replace(R.id.layout,new DFragment());
                break;
            }
        }
        transaction.commit();
    }
}
